package com.parrots.sample.dao.jpa;

import java.util.List;

import com.parrots.sample.dao.MenuDao;
import com.parrots.sample.entity.Resource;

/**
 * This class interacts with Spring's HibernateTemplate to save/delete and
 * retrieve resource objects.
 */
public class MenuDaoJpa extends GenericDaoJpa<Resource, Long> implements MenuDao {

    /**
     * Constructor that sets the entity to User.class.
     */
    public MenuDaoJpa() {
        super(Resource.class);
    }

    /**
     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public List<Resource> getMenus() {
        return getJpaTemplate().find("from Resource r where r.type = ? order by length(r.value), r.value", Resource.TYPE_MENU);
    }

}
